package com.hex.ds.hdtp.core.web.script.analyze.controller;

import com.hex.ds.hdtp.core.app.common.page.dto.PageDto;
import com.hex.ds.hdtp.core.app.script.analyze.dto.request.ScriptAnalyzeListRequestDto;
import com.hex.ds.hdtp.core.app.script.analyze.service.IScriptAnalyzeListService;
import com.hex.ds.hdtp.core.web.common.page.PageVo;
import com.hex.ds.hdtp.core.web.common.page.converter.IPageVoAndPageDtoConverter;
import com.hex.ds.hdtp.core.web.script.analyze.converter.IScriptAnalyzeListVoConverter;
import com.hex.ds.hdtp.core.web.script.analyze.vo.query.ScriptAnalyzeListQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author gj.xu
 * @Date 2023/12/11
 */
@Slf4j
@RestController
@Api(tags = "003-脚本分析：脚本清单")
@RequestMapping("/api/script/analyze/list")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptAnalyzeListController {

    private final IScriptAnalyzeListVoConverter converter;

    private final IPageVoAndPageDtoConverter pageVoAndPageDtoConverter;

    private final IScriptAnalyzeListService scriptAnalyzeListService;

    @GetMapping
    @ApiOperation("脚本分析清单-分页查询")
    public ResponseEntity queryListByPage(ScriptAnalyzeListQueryVo scriptAnalyzeListQueryVo, PageVo pageVo) {
        log.debug("进入到【ScriptAnalyzeListController.queryListByPage】方法,参数：{}" + scriptAnalyzeListQueryVo.toString());
        final PageDto pageDto = pageVoAndPageDtoConverter.toPageDto(pageVo);
        ScriptAnalyzeListRequestDto requestDto = converter.toScriptAnalyzeListRequestDto(scriptAnalyzeListQueryVo);
        return ResponseEntity.ok(scriptAnalyzeListService.queryListByPage(requestDto, pageDto));
    }

    @GetMapping(value = "/queryConsanguinityList")
    @ApiOperation("脚本分析清单血缘-分页查询")
    public ResponseEntity queryConsanguinityListByPage(ScriptAnalyzeListQueryVo scriptAnalyzeListQueryVo, PageVo pageVo) {
        log.debug("进入到【ScriptAnalyzeListController.queryConsanguinityListByPage】方法,参数：{}" + scriptAnalyzeListQueryVo.toString());
        final PageDto pageDto = pageVoAndPageDtoConverter.toPageDto(pageVo);
        ScriptAnalyzeListRequestDto requestDto = converter.toScriptAnalyzeListRequestDto(scriptAnalyzeListQueryVo);
        return ResponseEntity.ok(scriptAnalyzeListService.queryConsanguinityListByPage(requestDto, pageDto));
    }

}
